<?php
namespace app\login\controller;
use think\Controller;
use think\Request;
use think\captcha\Captcha;
use Behavior\LoginBehavior;
use Service\TimeService as Time;
class admin extends Controller{
    public function Index()
    {
        $this->title = "后台登录";
        return $this->fetch('login');
    }
    /**
     * 验证码
     */
    public function Captcha()
    {
        $config =    [
            // 验证码字体大小
            'fontSize'    =>    30,    
            // 验证码位数
            'length'      =>    5,   
            // 关闭验证码杂点
            'useNoise'    =>    false,
            'codeSet' =>'1234567890',
            'useCurve'=>false, 

        ];
        $captcha = new Captcha($config);
        return $captcha->entry();
    }
    /**
     * 登录检测
     */
    public function submit_login()
    {
        $info = input('post.');
        $request = new Request();
        $Ip= $request->ip(0,false);
        $info['loginip']=$Ip;
        $info['logintime'] = Time::getNowTime(1);
        return LoginBehavior::loginCheck($info);
    }
    
    public function NOlogin()
    {
        $this->error('请登录后进行相关操作');
    }
}